<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>添加快递员</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">姓名</td><td class="content_right"><input class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input  class="input" placeholder="请输入手机号"></td>
					</tr>
					<tr>
						<td class="text-right">身份证号码</td><td class="content_right"><input  class="input" placeholder="请输入身份证号"></td>
					</tr>
					<tr>
						<td class="text-right">密码</td><td class="content_right"><input  class="input" placeholder="请输入密码"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="doit">立即提交</span> <span id="reset" class="btn">重置</span> </td>
					</tr>
				</table>
				
				
			</div>
		</div>
		<script src="../../assets/layui.all.js"></script>
		<script src="/qrcode/jquery2.1.4.js"></script>
		<script src="/layer/layer.js"></script>
	<script>
		$(function () {
			function uphone() {
				//手机号码函数
					//获取手机号码值
					var number = $("input:eq(1)").val();
					//由1开头的11位整数
					if(number.match(/^1[0-9]{10}$/) == null){
						layer.msg("手机号不正确");
						return false;
					}
					return true;
				}

				function idCard() {
					//身份证判断  只要是十三位数字就可
					//获取身份证信息
					var id_card = $("input:eq(2)").val();
					var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
					if(!reg.test(id_card)){
						layer.msg('身份证号有误');
						return false;
					}
					return true;
				}


			$("#doit").click(function () {
				//判断身份证号和电话是否过关
				if(uphone() && idCard()) {
					//提示加载中
					var windowId = layer.load();
					//获取输入框中的值
					var username = $("input:eq(0)").val();
					var userPhone = $("input:eq(1)").val();
					var id_card = $("input:eq(2)").val();
					var password = $("input:eq(3)").val();
					//ajax交互
					$.post("/user/insert.do", {
						username: username,
						userPhone: userPhone,
						id_card: id_card,
						password: password
					}, function (data) {
						layer.close(windowId);
						layer.msg(data.result);
						if (data.status == 0) {
							//录入成功  表单恢复默认
							$("input").val("");

						} else {
							//录入失败
						}
					});
				}
			});
		});
	</script>
	</body>
</html>
